package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class DECLAGLOBALFactory extends AbstractTokenVisitorFactory {

	private static DECLAGLOBALFactory INSTANCE;
	
	private DECLARACION2Factory declaracion2Factory;
	private DECG2Factory decg2Factory;

	
	public static DECLAGLOBALFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new DECLAGLOBALFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			declaracion2Factory = DECLARACION2Factory.getInstance();
			decg2Factory = DECG2Factory.getInstance();
		}
	};
	
	private DECLAGLOBALFactory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return declaracion2Factory.makeChainedVisitor(decg2Factory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return declaracion2Factory.makeChainedVisitor(decg2Factory.makeVisitor());
	}
	
	
}
